import java.util.Date;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;

public class Main {
    public static void main(String[] args) throws InterruptedException {
        //创建DelayQueue
        DelayQueue<Task> queue = new DelayQueue<>();
        queue.add(new Task(10,"task1"));
        queue.add(new Task(5,"task2"));
        queue.add(new Task(20,"task3"));
        System.out.println("添加完成成员的时间");
        //延时获取成员
        while(!queue.isEmpty()){
            Task task = queue.take();
            System.out.println(new Date()+"从延时队列获取成员:"+task.getName());
            System.out.println(new Date()+"队列目前的大小"+queue.size());
        }
    }
}
